// import axios from 'axios'
import qs from 'qs'
import request from './request'

// 精品推荐接口
export const JingpinApi = () => request.get('/products/recommend')

// 热门兑换接口
export const HotApi = () => request.get('/products/hot')

// 发送注册短信验证码 /sendSMS (npm i qs 或者 yarn add qs)
export const getCodeApi = (params) => request.post('/sendSMS', qs.stringify(params))

// 手机号验证码登录(含注册) /phoneRegin
export const LoginApi = (params) => request.post('/phoneRegin', qs.stringify(params))

// 获取用户信息 /shop/userProfiles
export const UserInfoApi = () => request.get('/shop/userProfiles')

// 微信登录（这个接口必须用qs对数据进行格式化）
export const WeiXinLoginApi = (params) => request.post('/wechatUsers/PCLogin', qs.stringify(params));

// 手机绑定微信 /wechatUsers/PCLogin
export const BindWechatApi = (params) => request.post('/wechatUsers/binding', qs.stringify(params));

// 手机解绑微信 (登录状态下)
export const UnBindWechatApi = () => request.put('/wechatUsers/unbindingWeChat');

// 商品页面数据渲染
export const GoodsDataApi = (params) => request.get('/products', {params})

// 商品详情接口
export const GoodsDetailsApi = (params) => request.get(`/products/${params}`)

// 查看购物车接口
export const CartDataApi = () => request.get('/shop/carts');

// 购物车删除商品
export const CartDelApi = (params) => request.delete(`/shop/carts?productIds=${params.id}`);

// 加入购物车
export const CartAddApi = (params) => request.post(`/shop/carts/add`, qs.stringify(params));
